<admintpl file="header" />


<link href="__TMPL__Public/assets/css/infomation.css" rel="stylesheet" />
<style type="text/css">
.innertable{
    width: 100%;
}
.innertable tr td{
border:1px solid #eee;
}
.innertable tr td:first-child{
border-top:none;
border-left: none;
}
.innertable tr td:last-child{
border-top:none;
border-right: none;
}
.innertable tr:last-child td:first-child{
border:none;
border-right: 1px solid #eee;
}
.innertable tr:last-child td:last-child{
border:none;
}
</style>
</head>
<body>
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:U('EngineeringChangeOrder/index')}">工程变更单管理</a></li>
            <if condition="($Role eq 2) AND ($userrole['role'] eq 5)">
            <li><a href="{:U('EngineeringChangeOrder/add')}">新增工程变更单</a></li>
            </if>
            <li class="active"><a href="{:U('EngineeringChangeOrder/view', array('id'=>I('request.id/s','')))}">查看工程变更单</a></li>
        </ul>  
        <section class="tab-pane active fade in" id="access">
            <div class="row">
                <div class="col-xs-12 col-md-12 col-lg-12">
                    <div class="panel panel-info">

                        <div class="panel-body">
                            <form method="post" class="form-horizontal " action="{:U('EngineeringChangeOrder/audit_post')}">
                                    <input type="hidden" name="table_id" value="{$result.id}" />
                                    <input type="hidden" name="audit_level" value="{$result.audit_level}" />
                                <div class="row tg-header">
                                    <div class="col-md-12 text-center">
                                        <h3>工程变更单</h3>
                                        <hr />
                                    </div>

                                    <div class="col-md-12">
                                        <p class="tg-to"><label>工程名称:</label><input type="text" class="input-xt input-deptname"  disabled value="{$job_name}" readonly/></p>

                                        <p class="pull-right tg-serialnum"><label>编号:</label><input class="input-xt" name="code"
                                        value="{$result.code}" required/></p>
                                    </div>
                                </div>

                                <table class="table table-bordered">
                                    <tr>
                                        <td style="border-right:none !important;" colspan="2">
                                            
                                                <p>
                                                    <label>致：<input type="text" class="input-xt input-deptname"  
                                                        name="consignee_department" value="{$result.consignee_department}" required/></label>
                                                </p>
                                                <p class="indent20">
                                                    由于<input type="text" class="input-xt" style="width: 350px;" name="main_content" value="{$result.main_content}" required/>
                                                    原因，兹提出<input type="text" class="input-xt " style="width: 350px;" name="project_name" value="{$result.project_name}" required/>工程变更，请予以审批。
                                                </p>
                                                <p></p>
                                                <p class="indent20">
                                                    附件
                                                    <div class="controls" style="margin-left: 20px">
                                                       <ol>
                                                        <if condition="$result['audit_level'] eq 1">
                                                            <li>
                                                                <span style="width:200px !important;">变更内容</span>
                                                                   <a href="javascript:void(0);" class="btn upBtn btn-primary" name="attachement_1" style="padding: 6px;margin-left:15px; margin-bottom: 15px; line-height: 0.7em;">上传</a>
                                                                   <span class="controls" style="margin-left:10px;">   
                                                                       <input type="hidden" name="attachement_1" value="{$result.attachement_1}">    
                                                                       <input type="hidden" name="attachement_1_name" value="{$result.attachement_1_name}">    
                                                                    {$result.attachement_1_name}
                                                                   </span>
                                                               </li>
                                                               <li>
                                                                <span style="width:200px !important;">变更设计图</span>
                                                                   <a href="javascript:void(0);" class="btn upBtn btn-primary" name="attachement_2" style="padding: 6px;margin-left:15px; margin-bottom: 15px;line-height: 0.7em;">上传</a>
                                                                   <span class="controls" style="margin-left:10px;">   
                                                                       <input type="hidden" name="attachement_2" value="{$result.attachement_2}">    
                                                                       <input type="hidden" name="attachement_2_name" value="{$result.attachement_2_name}">    
                                                                    {$result.attachement_2_name}
                                                                   </span>
                                                               </li>
                                                               <li>
                                                                <span style="width:200px !important;">相关会议纪要</span>
                                                                   <a href="javascript:void(0);" class="btn upBtn btn-primary" name="attachement_3" style="padding: 6px;margin-left:15px; margin-bottom: 15px;line-height: 0.7em;">上传</a>
                                                                   <span class="controls" style="margin-left:10px;">   
                                                                       <input type="hidden" name="attachement_3" value="{$result.attachement_3}">    
                                                                       <input type="hidden" name="attachement_3_name" value="{$result.attachement_3_name}">    
                                                                    {$result.attachement_3_name}
                                                                   </span>
                                                               </li>
                                                               <li>
                                                                <span style="width:200px !important;">其他</span>
                                                                   <a href="javascript:void(0);" class="btn upBtn btn-primary" name="attachement_4" style="padding: 6px;margin-left:15px; margin-bottom: 15px;line-height: 0.7em;">上传</a>
                                                                   <span class="controls" style="margin-left:10px;">   
                                                                       <input type="hidden" name="attachement_4" value="{$result.attachement_4}">    
                                                                       <input type="hidden" name="attachement_4_name" value="{$result.attachement_4_name}">    
                                                                    {$result.attachement_4_name}
                                                                   </span>
                                                               </li>
                                                           <else />
                                                               <li>变更内容<br />
                                                                   <a href="javascript:void(0);" class="fileDownload" path="{$result.attachement_1}" name="{$result.attachement_1_name}">{$result.attachement_1_name}</a>
                                                               </li>
                                                               <li>变更设计图<br/>
                                                                   <a href="javascript:void(0);" class="fileDownload" path="{$result.attachement_2}" name="{$result.attachement_2_name}">{$result.attachement_2_name}</a>
                                                               </li>
                                                               <li>相关会议纪要<br />
                                                                   <a href="javascript:void(0);" class="fileDownload" path="{$result.attachement_3_results}" name="{$result.attachement_3_name}">{$result.attachement_3_name}</a>
                                                               </li>
                                                               <li>其他<br/>
                                                                   <a href="javascript:void(0);" class="fileDownload" path="{$result.attachement_4}" name="{$result.attachement_4_name}">{$result.attachement_4_name}</a>
                                                               </li>
                                                           </if>
                                                       </ol>
                                                        <input type="file" id="upFile" name="upFile" style="display:none" />
                                                    </div>
                                                </p>
                                                <div class="signature signaturetop0">
                                                    <p>
                                                        变更提出单位：
                                                    </p>
                                                    <p>
                                                        负责人：
                                                    </p>

                                                </div>
                                                <p class="signature-date">
                                                    <span>{$result.publish_time|substr=0,4}&nbsp;年&nbsp;{$result.publish_time|substr=5,2}月&nbsp;{$result.publish_time|substr=8,2}日</span>
                                                </p>         
                                        </td>
                                    </tr>
                                    <tr>
                                        <td width="10%" class="td-center">工程量增/减</td>
                                        <td><input type="text" name="" class="input-x0" readonly value="{$result.quantitychange}"></td>
                                    </tr>
                                    <tr>
                                        <td width="10%" class="td-center">费用增/减</td>
                                        <td><input type="text" name="" class="input-x0" readonly value="{$result.cost_change}" ></td>
                                    </tr>
                                    <tr>
                                        <td width="10%" class="td-center">工期变化</td>
                                        <td><input type="text" name="" class="input-x0" readonly value="{$result.duration_changed}"></td>
                                    </tr>

                                    <tr>

                                        <td colspan="2">
                                        <table class="innertable">
                                            <tr>
                                                <if condition="$audit[1] AND $result['audit_level'] egt 1">
                                                <td width="50%" class="td-center">
                                                	<label>
                                                    <if condition="$audit[1][0]['audit_status'] eq '1'">
                                                        &nbsp;同意
                                                    <else />
                                                        &nbsp;驳回
                                                    </if>
                                                        <textarea style="height:100%; width:100%" readonly>{$audit.1.audit_reason}</textarea>
                                                    </label>
                                                    <div class="text-center">
                                                        <p>施工项目经理部（盖章）</p>
                                                        <p>项目经理（签字）</p>
                                                    </div>
                                                </td>
                                                </if>
                                                <if condition="$audit[3] AND $result['audit_level'] egt 5">
                                                <td width="50%" class="td-center">
                                                	<label>
                                                        <if condition="$audit[3][0]['audit_status'] eq '1'">
                                                        &nbsp;同意
                                                    <else />
                                                        &nbsp;驳回
                                                    </if>
                                                        <textarea style="height:100%; width:100%" readonly>{$audit.3.audit_reason}</textarea>
                                                    </label>
                                                    <div class="text-center">
                                                        <p>项目监理机构（盖章）</p>
                                                        <p>总监理工程师（签字）</p>
                                                    </div>
                                                </td>
                                                </if>
                                                <if condition="$audit[5] AND $result['audit_level'] egt 7">
                                                <td width="50%" class="td-center">
                                                  <label>
                                                        <if condition="$audit[5][0]['audit_status'] eq '1'">
                                                        &nbsp;同意
                                                    <else />
                                                        &nbsp;驳回
                                                    </if>
                                                        <textarea style="height:100%; width:100%" readonly>{$audit.3.audit_reason}</textarea>
                                                    </label>
                                                    <div class="text-center">
                                                        <p>代建单位（盖章）</p>
                                                        <p>代建负责人（签字）</p>
                                                    </div>
                                                </td>
                                                </if>
                                            </tr>
                                            <tr>
                                                <if condition="$audit[7] AND $result['audit_level'] egt 11">
                                                <td width="50%" class="td-center">
                                                	<label>
                                                    <if condition="$audit[7][0]['audit_status'] eq '1'">
                                                        &nbsp;同意
                                                    <else />
                                                        &nbsp;驳回
                                                    </if>
                                                        <textarea style="height:100%; width:100%" readonly>{$audit.5.audit_reason}</textarea>
                                                    </label>
                                                    <div class="text-center">
                                                        <p>设计单位（盖章）</p>
                                                        <p>设计负责人（签字）</p>
                                                    </div>
                                                </td>
                                                </if>
                                                <if condition="$audit[9] AND $result['audit_level'] egt 9">

                                                <td width="50%" class="td-center">
                                                	<label>
                                                    <if condition="$audit[9][0]['audit_status'] eq '1'">
                                                        &nbsp;同意
                                                    <else />
                                                        &nbsp;驳回
                                                    </if>
                                                        <textarea style="height:100%; width:100%" readonly >{$audit.7.audit_reason}</textarea>
                                                    </label>
                                                    <div class="text-center">
                                                        <p>建设单位（盖章）</p>
                                                        <p>负责人（签字）</p>
                                                    </div>
                                                </td>
                                                </if>
                                            </tr>
                                        </table>
                                        </td>
                                    </tr>
                                    <if condition="$result['audit_status'] eq '2'">
                                        <tr>
                                            <td colspan="4">
                                                <label>审查意见：&nbsp;驳回</label>
                                                <textarea style="height:50px; width:100%" readonly >{$reject.audit_reason}</textarea>
                                            </td>
                                        </tr>
                                    </if>
                                    <if condition="$isAudit eq '2'">
                                      <tr>
                                            <td colspan="4">
                                                <label>审查意见：
                                                    <label style="width:50px;"><input type="radio" name="audit_status" value="1" checked />&nbsp;同意</label>
                                                    <label style="width:50px;"><input type="radio" name="audit_status" value="2" />&nbsp;驳回</label>
                                                </label>
                                                <textarea style="height:50px; width:100%" name="audit_reason" ></textarea>
                                            </td>
                                        </tr>
                                    </if>
                                <if condition="$is_last_user eq 1">
                                    <input type="hidden" name="last_user" value="1" id="last_user">
                                    <tr>
                                        <td colspan="4">
                                            选择设计公司
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4">
                                            <foreach name="design_company" item="l">
                                                <label style="margin-left: 20px;" for="d_{$l.id}">
                                                    <input type="checkbox" class="DesignCompanyCheckbox" name="departments[]"  id="d_{$l.id}" value="{$l.id}">{$l.department_name}
                                                </label>
                                            </foreach>
                                        </td>
                                    </tr>
                                </if>
                                </table>
                                <if condition="$result['audit_level'] eq 1">
                                    <input type="hidden" name="audit_status" value="1" />
                                    <input type="hidden" name="audit_reason" value="变更保存" />
                                </if>
                                <p class="text-muted tg-note">
                                    <small>注：本表一式四份，建设单位、项目监理机构、设计单位、施工单位各一份。</small>
                                </p>
                                <div class="form-actions">
                                       <if condition="$isAudit eq '2'">
                                        <a class="btn btn-primary clickBtn clicksavefly" href="javascript:void(0);">{:L('SAVE')}</a>
                                       </if>
                                       <if condition="$result['audit_status'] eq 3">
                                        <a class="btn btn-warning" href="javascript:$.print('#access');">打印</a>
                                       </if>
                                       <a class="btn btn-default" href="{:U('EngineeringChangeOrder/index')}">{:L('BACK')}</a>
                                </div>
                            </form>                   
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
    <script>
    </script>
    <script src="__PUBLIC__/js/common.js"></script>
    <script>
        $(document).ready(function(e) {
            if('{$result.audit_level}' != 1){
                $("input").attr("readonly", true);
            }

            // 点击保存按钮
            $(".clickBtn").click(function(){
                $(".tips_error").remove();
                var audit_status = $("input[name='audit_status']:checked").val();
                var audit_reason = $("textarea[name='audit_reason']").val();

                if(audit_status == '2' && audit_reason == ""){
                    $(".form-actions").append("<span class=\"tips_error\">驳回意见不允许为空！</span>");
                    $("textarea[name='audit_reason']").focus()
                    return false;
                }

                //不选择设计单位，也为空
                var DesignNum = parseInt( $('.DesignCompanyCheckbox').length );
                if(DesignNum > 0){
                    var DesignCheckedNum = $('.DesignCompanyCheckbox:checked').length;
                    var DesignCheckedNum = parseInt(DesignCheckedNum);
                    if(DesignCheckedNum < 1) {
                        alert('请指定设计单位');
                        return false;
                    }
                }
                // 表单提交
                $("form").submit();
            });

        });

    </script>
</body>
</html>